<h1 class="page-header">
    <small>编辑会员</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-1">
    <div class="panel-heading">
        <h4 class="panel-title">会员信息</h4>
    </div>
    <div class="panel-body">
        <form class="form-horizontal" id="memberForm" name="memberForm" action="" method="post">
            <input type="hidden" id="id" name="id" placeholder="会员号" value="${member.id}">
            <div class="form-group">
                <label class="col-md-3 control-label">等级：</label>
                <div class="col-md-9">
                    <select class="form-control" id="groupId" name="groupId">
                        <#list userGradeMap as grade>
                        <option <#if grade.id == member.gradeId>selected</#if> value="${grade.id}">${grade.name}</option>
                        </#list>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">手机号：</label>
                <div class="col-md-9">
                    <input type="text" id="mobile" class="form-control" name="mobile" placeholder="手机号"
                           maxlength="20" value="${member.mobile}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">姓名：</label>
                <div class="col-md-9">
                    <input type="text" id="name" class="form-control" name="name" placeholder="用户名最长20位" maxlength="20" value="${member.name}" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">生日：</label>
                <div class="col-md-9">
                    <input type="text" id="birthday" class="form-control" name="birthday" placeholder="生日，如：1998-10-30" maxlength="20" value="${member.birthday}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">积分数量：</label>
                <div class="col-md-9">
                    <input type="text" id="point" class="form-control" name="point" placeholder="积分数量，正整数" maxlength="20" value="${member.point}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">通讯地址：</label>
                <div class="col-md-9">
                    <input type="text" id="address" class="form-control" name="address" placeholder="通讯地址" maxlength="20" value="${member.address}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">状态：</label>
                <div class="col-md-9">
                    <select class="form-control" name="status" id="status">
                        <option value="A" <#if member.status == "A" > selected</#if>>已激活</option>
                        <option value="D" <#if member.status == "D" > selected</#if>>已禁用</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">创建时间：</label>
                <div class="col-md-9">
                    <input type="hidden" id="createTime"  name="createTime" placeholder="创建时间" value="${member.createTime}">
                    <label class="control-label">${member.createTime}</label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">备注信息：</label>
                <div class="col-md-9">
                    <textarea rows="5" class="form-control" id="description" name="description" maxlength="500" placeholder="备注信息">${member.description}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label"></label>
                <div class="col-md-9">
                    <button type="button" id="submitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-danger"
                            onclick="getData('${rc.contextPath}/backend/member/queryList','displayArea')">返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">

    jQuery.validator.addMethod("isMobile", function(value, element) {
        var length = value.length;
        var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
        return this.optional(element) || (length == 11 && mobile.test(value));
    }, "请正确填写手机号码");

    $(function () {

        $('#submitButton').click(function () {
            $('#memberForm').submit();
        });

        $('#memberForm').validate({
            rules: {
                realName: {
                    maxlength : 20
                }

            },
            messages: {
                realName: {
                    maxlength : "不能大于20个字符"
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByFormParams('${rc.contextPath}/backend/member/create', 'displayArea', 'memberForm');
            }
        })
    })
</script>

